Inside Macintosh: QuickTime Components

Previous | Chapter Top | Chapter Contents | Next

General Data Management

While the base media handler isolates your component from the details of media data access, your derived media handler still needs to keep track of certain information in order to support movie playback and creation. This section discusses functions that help your media handler manage its information.

Your media handler may store proprietary information in its media. The Movie Toolbox calls two media handler functions in order to give you an opportunity to retrieve or store this information. The MediaPutMediaInfo function allows you to store your special information in your media. The MediaGetMediaInfo function delivers that data to your media handler.

The Movie Toolbox tells your media handler when its track has been enabled or disabled by calling your MediaSetActive function. The Movie Toolbox prepares your handler for playback by calling your MediaPreroll function. Whenever your media's playback rate changes, the Movie Toolbox calls your MediaSetRate function. Whenever the track that uses your media is edited, the Movie Toolbox calls your MediaTrackEdited function.

If the Movie Toolbox has called its SetMediaSampleDescription function on a sample description, it uses the MediaSampleDescriptionChanged function to notify your media handler of the change.

The Movie Toolbox allows tracks to be identified by various characteristics. For instance, it is possible to request that all tracks containing audio information be searched. To determine whether a track has a given characteristic, the Movie Toolbox queries the media handler for each track. The Movie Toolbox calls the MediaHasCharacteristic function with the specified characteristic.

The Movie Toolbox uses two functions to inform you about changes to your media's time environment. The MediaSetMediaTimeScale function allows the Movie Toolbox to change your media's time scale. The MediaSetMovieTimeScale function allows the Movie Toolbox to tell you when the movie's time scale has changed.

MediaPutMediaInfo

The MediaPutMediaInfo function allows your derived media handler to store proprietary information in its media.

pascal ComponentResult MediaPutMediaInfo (MediaHandler mh,
                                          Handle h);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
h
Contains a handle to storage into which your media handler may place its proprietary information. You determine the format and content of the data that you store in this handle. Your media handler must resize the handle as appropriate before you exit this function. Do not dispose of this handle--it is owned by the Movie Toolbox. The Movie Toolbox uses the base media handler to write this data to your media.

DESCRIPTION

The Movie Toolbox uses the MediaPutMediaInfo function to provide you an opportunity to store private data in your media. You determine the format and content of this data. The base media handler stores some information for you, including the media's transfer mode, opcolor, and sound balance. However, you may need to store additional information. For example, you may want to place a version number in each media you create.

Whenever the Movie Toolbox opens your media, it provides this private data to your media handler by calling your MediaGetMediaInfo function, which is described next.

Note that the Movie Toolbox may call this function before it calls your MediaInitialize function.

Your derived media handler should support this function if you need to store private data in your media.

RESULT CODES

Any Component Manager result code

MediaGetMediaInfo

The MediaGetMediaInfo function allows your derived media handler to obtain the private data you have stored in your media.

pascal ComponentResult MediaGetMediaInfo (MediaHandler mh,
                                          Handle h);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
h
Contains a handle to storage containing your media handler's proprietary information. Your media handler creates this private data when the Movie Toolbox calls your MediaPutMediaInfo function. Do not dispose of this handle--it is owned by the Movie Toolbox.

DESCRIPTION

If you placed private data into your media, the Movie Toolbox calls your media handler's MediaPutMediaInfo function whenever it opens your media. Your media handler determines the format and content of this private data. Note that the Movie Toolbox may call this function before it calls your MediaInitialize function.

Your derived media handler should support this function if you store private data in your media.

RESULT CODES

Any Component Manager result code

MediaSetActive

The MediaSetActive function allows the Movie Toolbox to enable and disable your media.

pascal ComponentResult MediaSetActive (MediaHandler mh,
                                          Boolean enableMedia);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
enableMedia
Contains a Boolean value that indicates whether your media is enabled or disabled. If this parameter is set to true , your media is enabled; if the parameter is false , your media is disabled.

DESCRIPTION

The Movie Toolbox calls your derived media handler's MediaSetActive function whenever your media is either enabled or disabled. Initially, your media is disabled. Subsequently, the enabled state of your media is controlled by the state of the track that is using your media. When that track is enabled, your media is enabled; when that track is disabled, your media is disabled. Applications can control the enabled state of a track by using the Movie Toolbox's SetTrackEnabled function.

Your derived media handler should support this function if you perform your own scheduling or if your media handler uses significant amounts of temporary storage. If you are doing your own scheduling (that is, you have set the handlerNoScheduler flag to 1 in the flags parameter of the MediaSetHandlerCapabilities function--see MediaSetHandlerCapabilities for more information about this function), your media handler needs to keep account of the media's active state so that you can properly respond to Movie Toolbox requests. When your media is disabled, you may choose to dispose of temporary storage you have allocated, so that the storage is available to other programs.

RESULT CODES

Any Component Manager result code

MediaPreroll

The MediaPreroll function allows the Movie Toolbox to prepare your media handler for playback.

pascal ComponentResult MediaPreroll (MediaHandler mh,
                                          TimeValue time, Fixed rate);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
time
Contains the starting time of the media segment to play. This time value is expressed in your media's time scale.
rate
Specifies the rate at which the Movie Toolbox expects to play the media. This is a 32-bit, fixed-point number. Positive values indicate forward rates; negative values correspond to reverse rates.

DESCRIPTION

Use this as an opportunity to load data from your media, so that when the Movie Toolbox starts to play, your media can play smoothly from the start.

RESULT CODES

Any Component Manager result code

MediaSetRate

The MediaSetRate function allows the Movie Toolbox to set your media's playback rate.

pascal ComponentResult MediaSetRate (MediaHandler mh,
                                          Fixed rate);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
rate
Contains a 32-bit, fixed-point number that indicates your media's new effective playback rate. This effective rate accounts for any master time bases that may be in use with the current movie. Positive values represent forward rates and negative values indicate reverse rates.

DESCRIPTION

The Movie Toolbox calls your derived media handler's MediaSetRate function whenever the movie's playback rate changes. The Movie Toolbox provides you with a new effective rate for your media. This effective rate accounts for any master time bases that may be in use with the current movie. Consequently, you may use this rate without having to further transform it.

You obtain the initial rate information from the effectiveRate field of the movie parameter structure that the Movie Toolbox provides to your MediaInitialize function.

Your derived media handler should support this function if you perform your own scheduling. If you are doing your own scheduling (that is, you have set the handlerNoScheduler flag to 1 in the flags parameter of the MediaSetHandlerCapabilities function--see MediaSetHandlerCapabilities for more information about this function), your media handler can use this function to determine when your media is playing, and the direction and rate of playback. This information can help you prepare for playback more efficiently.

RESULT CODES

Any Component Manager result code

MediaTrackEdited

The MediaTrackEdited function allows the Movie Toolbox to inform your derived media handler about edits to its track.

pascal ComponentResult MediaTrackEdited (MediaHandler mh);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

DESCRIPTION

The Movie Toolbox calls your derived media handler's MediaTrackEdited function whenever the track that is using your media is edited. While these edits do not directly affect the data in your media, they can change the way in which the movie uses your media's data.

Your derived media handler should support this function if you are caching location information about track edits, or if you are using any time values in the movie's time base. Whenever the Movie Toolbox calls this function, your media handler should recalculate this type of information.

RESULT CODES

Any Component Manager result code

MediaSampleDescriptionChanged

The MediaSampleDescriptionChanged function allows the Movie Toolbox to inform your media handler that its SetMediaSampleDescription function has been called for a specified sample description.

pascal ComponentResult MediaSampleDescriptionChanged
                                         (MediaHandler mh,
                                          long index);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
index
Specifies the index of the sample description that has been changed.

DESCRIPTION

If your media handler caches sample description structures for any reason, it should support the MediaSampleDescriptionChanged function so that it will know when to update or invalidate the contents of that cache.

RESULT CODES

Any Component Manager result code

MediaHasCharacteristic

The Movie Toolbox calls the MediaHasCharacteristic function with a specified characteristic to allow tracks to be identified by various attributes.

pascal ComponentResult MediaHasCharacteristic
                                         (MediaHandler mh,
                                          OSType characteristic,
                                          Boolean *hasIt);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
characteristic
Contains a constant that specifies the attribute of a track. Examples of characteristics that are currently defined are the Movie Toolbox constants VisualMediaCharacteristic and AudioMediaCharacteristic .
hasIt
Contains a pointer to a Boolean value that specifies whether the track has the attribute specified in the characteristic parameter. Set this value to true if the attribute applies to your media handler; otherwise, set this value to false .

DESCRIPTION

The Movie Toolbox might request the search of all tracks with audio data. For example, to find out if a track has a given attribute, the Movie Toolbox queries the media handler for each track by calling MediaHasCharacteristic with a particular constant specified in the characteristic parameter. If your media handler does not recognize a characteristic, return a value of false .

You should implement this function for any media handler that has characteristics in addition to spatial ones. If you have set the handlerHasSpatial capabilities flag, the base media handler automatically handles the VisualMediaCharacteristic constant for you.

RESULT CODES

Any Component Manager result code

MediaSetMediaTimeScale

The MediaSetMediaTimeScale function allows the Movie Toolbox to inform your media handler that your media's time scale has been changed.

pascal ComponentResult MediaSetMediaTimeScale
                                         (MediaHandler mh,
                                          TimeScale newTimeScale);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
newTimeScale
Specifies your media's new time scale.

DESCRIPTION

The Movie Toolbox calls your derived media handler's MediaSetMediaTimeScale function whenever your media's time scale is changed. Applications can change your media's time scale by using the Movie Toolbox's SetMediaTimeScale function. When the Movie Toolbox calls this function, your media handler should recalculate any time values you have stored that are expressed in your media's time coordinate system. Changing your media's time scale may also affect media playback.

You obtain the initial media time scale information from the mediaScale field of the movie parameter structure that the Movie Toolbox provides to your MediaInitialize function.

Your derived media handler should support this function if your media handler stores time information that pertains to its media.

RESULT CODES

Any Component Manager result code

MediaSetMovieTimeScale

The MediaSetMovieTimeScale function allows the Movie Toolbox to inform your media handler that the movie's time scale has been changed.

pascal ComponentResult MediaSetMovieTimeScale
                                         (MediaHandler mh,
                                          TimeScale newTimeScale);
mh
Identifies the Movie Toolbox's connection to your derived media handler.
newTimeScale
Specifies the movie's new time scale.

DESCRIPTION

The Movie Toolbox calls your derived media handler's MediaSetMovieTimeScale function whenever the movie's time scale is changed. Applications can change the movie's time scale by using the Movie Toolbox's SetMovieTimeScale function. When the Movie Toolbox calls this function, your media handler should recalculate any time values you have stored that are expressed in the movie's time coordinate system. Changing the movie's time scale may also affect playback of your media.

You obtain the initial movie time scale information from the movieScale field of the movie parameter structure that the Movie Toolbox provides to your MediaInitialize function.

Your derived media handler should support this function if your media handler stores time information in the movie's time coordinate system.

RESULT CODES

Any Component Manager result code


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next